from web3 import Web3
from web3.middleware import geth_poa_middleware
from enum import Enum

IPC_PATH = '/root/goerli/geth.ipc'
PROVIDER_URL = 'https://goerli.infura.io/v3/8b55e04e99464356a003d3b7032504aa'

class ProviderSource(Enum):
  LOCAL_IPC = 0
  INFURA_RPC = 1

def get_w3(source: ProviderSource):
  if source == ProviderSource.LOCAL_IPC:
    w3 = Web3(Web3.IPCProvider(IPC_PATH))
  else: 
    w3 = Web3(Web3.HTTPProvider(PROVIDER_URL))

  w3.middleware_onion.inject(geth_poa_middleware, layer=0)

  return w3

w3 = get_w3(ProviderSource.LOCAL_IPC)

